package com.lzh.controller;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.junit.Test;

import java.util.Objects;

/**
 * 客户端
 */
public class WebServiceTest {
    @Test
    public void test1() {
        // 创建动态客户端
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient("http://localhost:8080/services/MyWebService?wsdl");


        try {
            Object[] invoke = client.invoke("sendMessage", "哈哈");
            System.err.println(invoke[0]);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test2() {
        JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
        Client client = factory.createClient("http://localhost:8080/services/MyWebService?wsdl");
        try {
            Object[] getOrders = client.invoke("getOrders");

        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
